package com.tianzhu.service;

import java.util.List;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tianzhu.domain.Product;
import com.tianzhu.repositories.ProductRepo;

@Service
@Transactional
@Slf4j
public class ProductService {
	
	@Autowired
	ProductRepo productRepo;
	
	public List<Product> getProductList(){
		
		return productRepo.findAll();
	}

	public Product getProductById(Long id){
    	return productRepo.findOne(id);
    }

	public void addProduct(Product product){
    	 productRepo.save(product);
    }

	public void editProduct(Product product){
    	productRepo.save(product);
    }

	public void deleteProduct(Product product){
    	productRepo.delete(product);
    }

}
